from pyecharts.charts import Bar,Timeline
from pyecharts.options import LabelOpts
from pyecharts.globals import ThemeType
bar = Bar()

bar.add_xaxis(['中国','美国','英国'])
bar.add_yaxis('GDP',[20,30,10],label_opts=LabelOpts(position='right'))
bar.reversal_axis()

bar1 = Bar()

bar1.add_xaxis(['中国','美国','英国'])
bar1.add_yaxis('GDP',[30,50,20],label_opts=LabelOpts(position='right'))
bar1.reversal_axis()

bar2 = Bar()

bar2.add_xaxis(['中国','美国','英国'])
bar2.add_yaxis('GDP',[50,60,30],label_opts=LabelOpts(position='right'))
bar2.reversal_axis() 

timeline = Timeline(
  {"theme": ThemeType.LIGHT}
)
timeline.add(bar,'1997')
timeline.add(bar1,'2005')
timeline.add(bar2,'2020')
timeline.add_schema(
  play_interval=1000,
  is_timeline_show=True,
  is_auto_play=True,
  is_loop_play=False

)
timeline.render('基础柱状图.html')


my_list = [['成都',23],['南京',66],['天津',99]]

# def sort_by_key(element):
#   return element[1]

# my_list.sort(key=sort_by_key,reverse=True)
my_list.sort(key=lambda element:element[1],reverse=True)
print(my_list)